import "./index.css";
import "./loading.css";

const cover = document.createElement('div');
cover.className = "modal-cover";

const modal = document.createElement('div');
modal.className = "modal";

modal.innerHTML =
    '<div class="sk-cube-grid">\n' +
    '    <div class="sk-cube sk-cube1"></div>\n' +
    '    <div class="sk-cube sk-cube2"></div>\n' +
    '    <div class="sk-cube sk-cube3"></div>\n' +
    '    <div class="sk-cube sk-cube4"></div>\n' +
    '    <div class="sk-cube sk-cube5"></div>\n' +
    '    <div class="sk-cube sk-cube6"></div>\n' +
    '    <div class="sk-cube sk-cube7"></div>\n' +
    '    <div class="sk-cube sk-cube8"></div>\n' +
    '    <div class="sk-cube sk-cube9"></div>\n' +
    '</div>';
const body = document.body; //获取body对象.
//动态插入到body中
body.insertBefore(cover, body.lastChild);
body.insertBefore(modal, body.lastChild);

let status = "off";

function onModal() {
    status = "on";
    cover.style.display = "block";   //显示遮罩层
    modal.style.display = "block";   //显示弹出层
}

function offModal() {
    status = "off";
    cover.style.display = "none";   //隐藏遮罩层
    modal.style.display = "none";   //隐藏弹出层
}

function getStatus() {
    return status;
}

export default {
    getStatus,
    onModal,
    offModal
}
